<template>
  <div>
    <h3>我是.sync的儿子</h3>
    <p>爸爸给了我零花钱---{{ money }}</p>
    <button @click="changeMoney"> 买好吃的</button>
    <button @click="hancldClick">尝试调用父组件传递过来的gcfn</button>
  </div>
</template>

<script>
export default {
  props: {
    money: {
      required: true,
      type: Number
    },
    gcfn: {
      type: Function,
      default: () => {}
    }
  },
  methods: {
    changeMoney() {
      // this.$emit('changeMoney', this.money - 10)
      this.$emit('update:money', this.money - 10)
    },
    hancldClick() {
      // console.log('click')
      this.gcfn(1, 2, 'false', { c: 3, d: 4 }) // 调用父组件传递过来的方法
      // this.gcfn()
    }
  }
}
</script>

<style>

</style>
